﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace SilentVoice.Models
{
    public partial class Account : Auditable
    {
        public Account()
        {
            this.Groups = new HashSet<Group>();
            this.Users = new HashSet<User>();
            this.Events = new HashSet<Event>();
        }
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }

        public virtual ICollection<Group> Groups { get; set; }
        public virtual ICollection<User> Users { get; set; }
        public virtual ICollection<Event> Events { get; set; }

        public override bool Equals(object obj)
        {
            if (obj == null || obj.GetType().DeclaringType != this.GetType().DeclaringType)
            {
                System.Console.WriteLine("they're not the same type, {0} {1}", obj.GetType().DeclaringType.ToString(), this.GetType().DeclaringType.ToString());
                return false;
            }

            Account other = (Account)obj;

            return this.Name.Equals(other.Name);
        }

        public override int GetHashCode()
        {
            return this.Name.GetHashCode();
        }
    }
}